<?php
require_once $_site->get_viewpath("mobile/common/authcheck");
require_once $_site->get_viewpath("mobile/common/header");

//查询管理员信息
$admin_objet=new manager();
$pid=$admin_objet->admin_project_id();

$typeAry=array(1=>'挖机装车 ',2=>'挖机计时',3=>'渣车登记');

$page=request('page',false,true,false,1);
$cond['pid']=$pid;
$cond['type']=0;
$cond['proid']=request('proid',true,false,false,0);
$cond['did']=request('did',true,false,false,0);

$cond['isdate']=request('isdate',true,false,false,1); //1-按日期 0-不按日期
$cond['date']=request('date');//开始时间
$cond['date_end']=request('date_end');//截止时间
//默认为当天
if($cond['date']==''){
    $nowdate=date('Y-m-d');
    $cond['date']=$nowdate.' 00:00';
}
//默认当天截止时间
if($cond['date_end']==''){
    $nowdate=date('Y-m-d');
    $cond['date_end']=$nowdate.' 23:59';
}

$cols='id,img,type,dno,time,ctime,dname,truck,dust';
$list=$admin_objet->record_search($cond,$page,20,$cols);

//查询条件
$project_ary=$admin_objet->project_search($pid);
//项目名称
if($cond['proid']){
   $pinfo=$admin_objet->project_info($cond['proid'],'title');
}
//设备列表
$device_list=$admin_objet->device_search($cond,1,1000);
//时间
$datestart=date('Y',strtotime('-1 year'));
$datestr=date('Y');

unset($cond['pid']);
$querystr=http_build_query($cond);
?>
</head>

	<body>
		<div class="headertwo clearfloat" id="header">
			<a href="javascript:history.go(-1)" class="fl box-s"><i class="iconfont icon-arrow-l fl"></i></a>
			<p class="fl"><?php echo $pinfo['title']?$pinfo['title'].' ':''; ?>全部记录</p>
			<a href="/mobile/center" class="fr"><i class="iconfont icon-gerenzhongxin fl"></i></a>
		</div>
		<div class="clearfloat" id="main">
			<div class="menu-list clearfloat am-sharetwo">
				<ul class="yiji" id="oe_menu">
					<li>
						<a href="#" class="inactive">项目<i></i></a>
						<ul style="display: none">
						<div class="menu_option2">
						    <li><a href="?<?php $pcond=$cond;unset($pcond['proid']);$pquerystr=http_build_query($pcond);echo $pquerystr;?>">全部项目</a></li>
						    <?php
						       if($project_ary[1]){
                                 foreach($project_ary[1] as $val){
						    ?>
							<li><a href="?<?php echo $pquerystr;?>&proid=<?php echo $val['id'];?>"><?php echo $val['title'];?></a></li>
							<?php
							   }}
							?>
						</div>
						</ul>
					</li>
					<li>
						<a href="#" class="inactive">车牌<i></i></a>
						<ul style="display: none">
						<div class="menu_option">
						    <li><a href="?<?php $dcond=$cond;unset($dcond['did']);$pquerystr=http_build_query($dcond);echo $pquerystr;?>">全部车牌</a></li>
						    <?php
						       if($device_list['rows']){
                                 foreach($device_list['rows'] as $val){
						    ?>
							<li><a href="?<?php echo $pquerystr;?>&did=<?php echo $val['did'];?>"><?php echo $val['car_number']; ?></a></li>
							<?php }}?>
						</div>
						</ul>
					</li>
					<li>
						<a href="#" class="inactive">时间<i></i></a>
						<ul style="display: none">
                            <li><a id="datebtn" href="?<?php $tcond=$cond;$tcond['isdate']=0;$pquerystr=http_build_query($tcond);echo $pquerystr;?>">不限时间</a></li>
                            <li><a href="javascript:;" dname="date_start" id="timebtn" data-options='{"value":"<?php echo $cond['date']; ?>","beginYear":<?php echo $datestart;?>,"endYear":<?php echo $datestr;?>}' class="btn time_choose">开始时间</a></li>
                            <li><a href="javascript:;" dname="date_end" data-options='{"value":"<?php echo $cond['date_end']; ?>","beginYear":<?php echo $datestart;?>,"endYear":<?php echo $datestr;?>}' class="btn time_choose">结束时间</a></li>
						</ul>
					</li>
				</ul>
			</div>

			<div class="<?php echo $list['rows']?'recom ':'';?>clearfloat recomtwo">
		    	<div class="content clearfloat box-s">

			 	    <?php
			 	       if($list['rows']){
                          foreach ($list['rows'] as $vo){
			 	    ?>
		    		<div class="list clearfloat fl box-s">
		    			    <a href="/mobile/recordinfoall?id=<?php echo $vo['id']?>">
			    			<div class="tu clearfloat">
			    				<span></span>
			    				<img src="<?php echo $vo['img'];?>"/>
			    			</div>
			    		    </a>
			    			<div class="right clearfloat">
			    				<div class="tit clearfloat">
			    					<p class="fl" style="width: 50%;"><?php echo $vo['dno'] ;?></p>
			    					<span class="fr"><samp><?php echo date('Y-m-d H:i:s',$vo['ctime']);?></samp></span>
			    				</div>
			    				<p class="recom-jianjie"><?php echo '车牌：'.$vo['dname'];?></p>
			    				<p class="recom-jianjie"><?php echo "类型：".$typeAry[$vo['type']];?></p>
			    			</div>
		    		</div>
		    		<?php
                       }}else{
		    		?>

						<div class="empty-list clearfloat" id="main">
							<i class="iconfont icon-meineirong"></i>
                            <p>
                                <?php if($cond['isdate']){ echo $cond['date'].' 至 '.$cond['date_end'];?><br/>没有找到相应记录！
                                <?php }else{ ?>
                                    没有找到相应记录！
                                <?php } ?>
                            </p>
						</div>

                     <?php } ?>

		    	</div>
		    </div>

			<?php
			   if($list['page_count']>1){
			?>
			<br/>
			<div class="mui-content-padded">
				<ul class="mui-pager">
					<li class="mui-previous">
					    <?php
					       if($page<=1){
					    ?>
						<a href="javascript:;">上一页</a>
						<?php
                           }else{
						?>
						<a href="?<?php echo $querystr;?>&page=<?php echo $page-1;?>">上一页</a>
						<?php } ?>
					</li>
					<li class="mui-disabled">
						<span> <?php echo $page.' / '.$list['page_count'].'  ('.$list['row_count'].')'; ?> </span>
					</li>
					<li class="mui-next">
					    <?php
					       if($page>=$list['page_count']){
					    ?>
						<a href="javascript:;">下一页</a>
						<?php
                           }else{
						?>
						<a href="?<?php echo $querystr;?>&page=<?php echo $page+1;?>">下一页</a>
						<?php } ?>
					</li>
				</ul>
			</div>
			<?php } ?>

	    </div>
	</body>
<form action="" method="get" id="search_form">
    <input type="hidden" name="type" value="<?php echo $type; ?>">
    <input type="hidden" name="proid" value="<?php echo $cond['proid']; ?>">
    <input type="hidden" name="did" value="<?php echo $cond['did']; ?>">
    <input type="hidden" name="isdate" value="1">
    <input type="hidden" name="date" id="g_date_start" value="<?php echo $cond['date']; ?>">
    <input type="hidden" name="date_end" id="g_date_end" value="<?php echo $cond['date_end']; ?>">
</form>
	<script type="text/javascript" src="/static/mobile/js/psong.js" ></script>
	<script type="text/javascript" src="/static/mobile/js/menu.js" ></script>
	<link href="/static/mobile/css/mui.picker.min.css" rel="stylesheet" />
	<script src="/static/mobile/js/mui.picker.min.js"></script>
	<script>
		mui.init();
		(function($) {
            var btns=$(".time_choose");
            btns.each(function(i, btn) {
                btn.addEventListener('tap', function () {
                    var optionsJson = this.getAttribute('data-options') || '{}';
                    var options = JSON.parse(optionsJson);
                    var id = this.getAttribute('dname');
                    var picker = new $.DtPicker(options);
                    menuinit();
                    picker.show(function (rs) {
                        picker.dispose();
                        document.getElementById("g_"+id).value=rs.text;
                        document.getElementById("search_form").submit();
                    });
                }, false);
            })
		})(mui);
	</script>
</html>
